$(function() {
	//初始化
	getMonitorList();
	//查询
	$(document)
		.on('click', '._monitor_search', function() {
			getMonitorList({
				page: 1, //当前页码
				pagesize: 20, //data-value
				service_id: $('#serviceone .select-list ul .selected').attr('data-value'),
				api_id: $('#servicetwo .select-list ul .selected').attr('data-value'),
				cycle_type: $('#servicethree .select-list ul .selected').attr('data-value')
			});
		});
	//切换分页时
	function gotopage(current_page) {
		//获取分页数据
		getApiList({
			page: current_page,
			pagesize: 20,
			service_id: $('._service_change').val(),
			api_id: $('._service_api_option').val(),
			services: JSON.parse($('._all_services').val()),
			all_services: JSON.parse($('._all_array_service').val()),
			all_apis: JSON.parse($('._all_array_apis').val()),
			cycle_type: $('#servicethree .select-list ul .selected').attr('data-value')
		});
	}

	//ajax获取数据
	function getMonitorList(option) {
		var default_option = {
			page: 1, //当前页码
			pagesize: 20,
			service_id: -1, //全部
			api_id: 0, //无
			services: JSON.parse($('._all_services').val()),
			all_services: JSON.parse($('._all_array_service').val()),
			all_apis: JSON.parse($('._all_array_apis').val()),
			cycle_type: $('#servicethree .select-list ul .selected').attr('data-value')
		}
		//发送的数据
		option = $.extend({}, default_option, option);
		$.ajax({
			url: '/apiworks/ajaxMonitorList.html',
			type: 'POST',
			dataType: 'json',
			async: true,
			data: option,
			success: function(req) {
				if(req.status == 200) {
					if(req.data != null) {
						//渲染数据
						var html = template('monitor_list', {
							list: req.data
						});
						document.getElementById('monitor_list_content').innerHTML = html;
					} else {
						document.getElementById('monitor_list_content').innerHTML = '<div class="wudy"></div>';
					}
				} else {
					show_msg({
						msg: req.msg,
						type: 'error',
						time: 2000
					});
				}
				return false;
			},
			error: function() {
				show_msg({msg:'系统异常',type:'error',time:2000});
			}
		});
	}
})